<?php

declare (strict_types = 1);

namespace app\admin\controller\auth;

use think\Request;
use sheep\controller\Backend;
use app\admin\model\auth\AdminLog as AdminLogModel;
use sheep\exception\SheepException;

class AdminLog extends Backend
{
    protected function initialize()
    {
        $this->model = new AdminLogModel;
        $this->childAdminIds = $this->auth()->getChildAdminIds(true);
    }

    /**
     * 管理员日志列表
     *
     * @return \think\Response
     */
    public function list(Request $request)
    {
        // TODO-ldh: 只能看自己下级的日志
        $adminLogs = $this->model->sheepFilter()->whereIn('admin_id', $this->childAdminIds)
                    ->with('admin')->paginate((int)request()->param('list_rows', 10));

        return success('获取成功', $adminLogs);
    }
}
